<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ page import="java.util.List" %>
<%@ page import="java.text.SimpleDateFormat" %>
<%@ page import="beans.Shenqing" %>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <title>公司用车管理系统（司机队长）- 我的待办</title>
    <style>
        /* 全局样式 */
        body {
            margin: 0;
            padding: 0;
            font-family: "Microsoft YaHei", Arial, sans-serif;
            background: #f6f6f6;
            color: #333;
        }

        /* 头部样式 */
        .header {
            background: #183a8a;
            color: #fff;
            font-size: 2rem;
            font-weight: bold;
            padding: 10px 0 10px 10px;
            letter-spacing: 2px;
            display: flex;
            align-items: center;
            justify-content: space-between;
        }
        .header-right {
            display: flex;
            align-items: center;
            margin-right: 30px;
            font-size: 1rem;
        }
        .user-icon {
            width: 40px;
            height: 40px;
            border-radius: 50%;
            background: #fff;
            color: #183a8a;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 2rem;
            margin-right: 10px;
        }
        .user-info {
            margin-right: 20px;
            color: #fff;
        }
        .bell-icon {
            font-size: 1.3rem;
            margin-right: 20px;
            color: #fff;
        }
        .logout {
            color: #fff;
            text-decoration: none;
            margin-left: 10px;
            font-size: 1rem;
        }

        /* 主体容器 */
        .container {
            display: flex;
            height: calc(100vh - 56px);
        }

        /* 侧边栏样式 */
        .sidebar {
            width: 220px;
            background: #183a8a;
            display: flex;
            flex-direction: column;
            padding-top: 10px;
            box-shadow: 2px 0 8px rgba(24,58,138,0.05);
        }
        .menu-item {
            color: #fff;
            padding: 18px 0 18px 32px;
            font-size: 1.15rem;
            cursor: pointer;
            border-left: 5px solid transparent;
            transition: background 0.2s, border 0.2s;
            text-decoration: none;
            display: block;
        }
        .menu-item.active, .menu-item:hover {
            background: #2450a7;
            border-left: 5px solid #fff;
            font-weight: bold;
            box-shadow: 0 4px 8px rgba(24,58,138,0.10);
        }

        /* 主内容区域 */
        .main-content {
            flex: 1;
            padding: 20px 40px;
            overflow-y: auto;
        }

        /* 搜索容器 */
        .search-container {
            margin-bottom: 30px;
            padding: 20px;
            background: #fff;
            border-radius: 8px;
            box-shadow: 0 2px 8px rgba(0,0,0,0.1);
        }

        /* 搜索表单 */
        .search-form {
            display: flex;
            align-items: center;
            flex-wrap: wrap;
            gap: 15px;
        }

        /* 搜索输入框 */
        .search-input {
            flex: 1;
            min-width: 300px;
            padding: 12px 20px;
            border: 1px solid #ddd;
            border-radius: 6px;
            font-size: 1.1rem;
            box-sizing: border-box;
        }

        /* 搜索按钮 */
        .search-btn {
            padding: 12px 25px;
            background: #1da1e7;
            color: white;
            border: none;
            border-radius: 6px;
            cursor: pointer;
            font-size: 1.1rem;
            transition: background 0.2s;
        }
        .search-btn:hover {
            background: #2176b8;
        }

        /* 申请列表 */
        .application-list {
            margin-top: 20px;
            background: #fff;
            border-radius: 8px;
            padding: 20px;
            box-shadow: 0 2px 8px rgba(0,0,0,0.1);
        }

        /* 申请项 */
        .application-item {
            padding: 20px;
            margin-bottom: 15px;
            background: #f8f9fa;
            border-radius: 6px;
            border-left: 5px solid #1da1e7;
            display: flex;
            justify-content: space-between;
            align-items: center;
            transition: transform 0.2s, box-shadow 0.2s;
        }
        .application-item:hover {
            transform: translateY(-2px);
            box-shadow: 0 4px 12px rgba(0,0,0,0.1);
        }

        /* 申请信息 */
        .application-info {
            flex: 1;
            font-size: 1.1rem;
        }

        /* 查看按钮 */
        .view-btn {
            padding: 10px 20px;
            background: #1da1e7;
            color: white;
            border: none;
            border-radius: 6px;
            cursor: pointer;
            font-size: 1rem;
            margin-left: 20px;
            transition: background 0.2s;
        }
        .view-btn:hover {
            background: #2176b8;
        }

        /* 无结果提示 */
        .no-results {
            text-align: center;
            padding: 30px;
            color: #666;
            font-size: 1.2rem;
        }

        /* 状态标签 */
        .status-badge {
            display: inline-block;
            padding: 5px 12px;
            color: white;
            border-radius: 4px;
            font-size: 0.9rem;
            margin-left: 15px;
        }

        /* 待审核图标 */
        .pending-icon {
            display: inline-block;
            padding: 4px 8px;
            background: #ffd700;
            color: #8b8000;
            border-radius: 4px;
            font-size: 0.9rem;
            margin-right: 10px;
            border: 1px solid #ffd700;
            animation: pulse 1.5s infinite;
        }

        /* 呼吸动画效果 */
        @keyframes pulse {
            0% { transform: scale(1); }
            50% { transform: scale(1.05); }
            100% { transform: scale(1); }
        }

        /* 响应式设计 */
        @media (max-width: 900px) {
            .sidebar {
                width: 120px;
            }
            .menu-item {
                padding-left: 15px;
                font-size: 1rem;
            }
            .search-form {
                flex-direction: column;
                align-items: stretch;
            }
            .search-input {
                width: 100%;
                min-width: auto;
            }
            .application-item {
                flex-direction: column;
                gap: 15px;
            }
            .view-btn {
                margin-left: 0;
                width: 100%;
            }
        }
    </style>
</head>
<body>
    <div class="header">
        <div>欢迎登录公司用车管理系统（司机队长）</div>
        <div class="header-right">
            <div class="user-icon">👤</div>
            <div class="user-info">账号：<%=session.getAttribute("username")%></div>
            <div class="bell-icon">🔔</div>
            <a href="${pageContext.request.contextPath}/LogoutServlet" class="logout">退出登录</a>
        </div>
    </div>

    <div class="container">
        <div class="sidebar">
            <a class="menu-item" href="DriversServlet?action=all3">系统首页</a>
            <a class="menu-item" href="DriversServlet?action=all2">个人中心</a>
            <a class="menu-item active" href="ShenqingServlet?action=all">我的待办</a>
            <a class="menu-item" href="UseOrderServlet?action=list">我处理的</a>
            <a class="menu-item" href="VehiclesServlet?action=all">全部车辆信息</a>
            <a class="menu-item" href="DriversServlet?action=all">全部司机信息</a>
        </div>

        <div class="main-content">
            <div class="search-container">
                <form class="search-form" action="${pageContext.request.contextPath}/ShenqingServlet" method="get">
                    <input type="hidden" name="action" value="search">
                    <input type="text" name="orderId" class="search-input" 
                           placeholder="请输入订单号" value="<%=request.getParameter("orderId")%>">
                    <button type="submit" class="search-btn">搜索</button>
                    <button type="button" class="search-btn" 
                            onclick="location.href='${pageContext.request.contextPath}/ShenqingServlet?action=all'">
                        重置
                    </button>
                </form>
            </div>

            <div class="application-list">
                <% 
                List<Shenqing> shenqingList = (List<Shenqing>)request.getAttribute("shenqingList");
                SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
                
                if(shenqingList == null || shenqingList.isEmpty()) { 
                %>
                    <div class="no-results">
                        <div>暂无待办任务</div>
                    </div>
                <% } else { 
                    for(Shenqing task : shenqingList) { 
                %>
                    <div class="application-item">
                        <div class="application-info">
                            <% if("未审核".equals(task.getStatus())) { %>
                                <span class="pending-icon">🕒 待审核</span>
                            <% } %>
                            <span>订单号：<%=task.getOrderId()%></span>
                            <span style="margin-left: 20px;">申请人：<%=task.getEmployeeId()%></span>
                            <span style="margin-left: 20px;">申请时间：<%=sdf.format(task.getDepartureTime())%></span>
                        </div>
                        <a href="${pageContext.request.contextPath}/pirt/driversBig/ShenqingDetail.jsp?orderId=<%=task.getOrderId()%>" 
                           class="view-btn">查看详情</a>
                    </div>
                <% } } %>
            </div>
        </div>
    </div>
</body>
</html>